import 'package:dash/contants/controllers.dart';
import 'package:dash/contants/style.dart';
import 'package:dash/widgets/cus_text.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class HMenuItem extends StatelessWidget {
  final String itemName;
  final void Function() onTap;

  const HMenuItem(this.itemName, {Key? key, required this.onTap})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    final width = MediaQuery.of(context).size.width;
    return InkWell(
      onTap: onTap,
      onHover: (value) => value
          ? menuController.onHover(itemName)
          : menuController.onHover("not Hovering"),
      child: Obx(
        () => Container(
          color: menuController.isHovering(itemName)
              ? lightGrey.withOpacity(.1)
              : Colors.transparent,
          child: Row(
            children: [
              Visibility(
                visible: menuController.isHoverOrActive(itemName),
                maintainSize: true,
                maintainState: true,
                maintainAnimation: true,
                child: Container(
                  width: 6,
                  height: 40,
                  color: dark,
                ),
              ),
              SizedBox(width: width / 80),
              Padding(
                padding: const EdgeInsets.all(16),
                child: menuController.getIconFor(itemName),
              ),
              menuController.isActive(itemName)
                  ? Flexible(
                      child: CusText(
                      itemName,
                      color: dark,
                      size: 18,
                      weight: FontWeight.bold,
                    ))
                  : Flexible(
                      child: CusText(itemName,
                          color: menuController.isHovering(itemName)
                              ? dark
                              : lightGrey)),
            ],
          ),
        ),
      ),
    );
  }
}
